The 2nd character in a string is at index 1.
public static String combine(String s1, String s2) {
String s3 = s1.substring(1);
String s4 = s2.substring(1);
String result = s3 + s4;
return result;
}
Function Call | Return Value | |||
---|---|---|---|---|
combine("Car", "wash") | → | |||
combine("Hello", " world") | → | |||
combine("5", "8") | → | |||
combine("Snow", "ball") | → | |||
combine("Rain", "boots") | → | |||
combine("Reading", "bat") | → | |||
combine("AAA", "Hi") | → | |||
combine("Hi", "there") | → | |||
combine(" ", " ") | → |
Experiment with this code on Gitpod.io